package com.example.mobile2021606163crw0427;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

public class TccRVAdapter extends RecyclerView.Adapter<TccRVAdapter.VH> {
    private List<Tcc> list;
    public TccRVAdapter(List<Tcc> list) {
        this.list = list;
    }
    static class VH extends RecyclerView.ViewHolder{
        TextView tvName,tvKw,tvMoney,tvkJl,tvDz;
        ImageView Imgtp;

        public VH(@NonNull View itemView) {
            super(itemView);
            tvName = itemView.findViewById(R.id.tv_main_name);
            tvKw = itemView.findViewById(R.id.tv_main_kw);
            tvMoney = itemView.findViewById(R.id.tv_main_money);
            tvkJl = itemView.findViewById(R.id.tv_main_jl);
            tvDz = itemView.findViewById(R.id.tv_main_dz);
            Imgtp = itemView.findViewById(R.id.imageView);
        }
    }

    @NonNull
    @Override
    public TccRVAdapter.VH onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.item_rv_main_title, parent, false);
        return new VH(view);
    }

    @Override
    public void onBindViewHolder(@NonNull TccRVAdapter.VH holder, int position) {
            Tcc tcc = list.get(position);
        holder.tvName.setText(tcc.getName());
        holder.tvKw.setText(tcc.getKw());
        holder.tvMoney.setText(tcc.getMoney());
        holder.tvkJl.setText(tcc.getJl());
        holder.tvDz.setText(tcc.getDz());
        holder.Imgtp.setImageResource(tcc.getImg());
    }

    @Override
    public int getItemCount() {
        return list.size();
    }
}
